package com.ali.juejin.base

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.ali.juejin.ui.activity.LoginActivity
import com.blankj.utilcode.util.SPUtils

open class BaseFragment: Fragment() {

    protected val sp by lazy { SPUtils.getInstance() }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initView()
        initData()
    }

    open protected fun initView(){

    }

    open protected fun initData(){

    }


    // 未登录则跳转到登录页
    fun interceptLogin():Boolean{
        val token = sp.getString("token","")
        if(token.isNullOrEmpty()){
            startActivity(Intent(context,LoginActivity::class.java))
            return false
        }
        return true
    }

}